<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: user
  Date: 2024/6/6
  Time: 9:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
session.setAttribute("username","admin");

    ArrayList lsdata=new ArrayList();
    lsdata.add("java");
    lsdata.add("mysql");
    lsdata.add("python");
    session.setAttribute("lsdata",lsdata);
%>
out标签演示效果<c:out value="${sessionScope.username}" default="游客"></c:out>
<br/>
set标签的演示效果<c:set var="userpwd" value="admin" scope="request"></c:set>
${userpwd}
<br/>
if标签的演示效果
<%--如果session中的username值不为空，则输出欢迎您：username--%>
<c:if test="${not empty sessionScope.username}">
    欢迎您：${sessionScope.username}
</c:if>
<br/>
choose、when、otherwise的效果演示
<%--在choose中可以添加多个when标签进行多分支的选择--%>
<c:choose>
    <c:when test="${not empty requestScope.username}">
        欢迎您：${requestScope.username}
    </c:when>
    <c:otherwise>
        欢迎您：游客
    </c:otherwise>
</c:choose>
<br/>
foreach标签的演示效果：
<c:forEach items="${sessionScope.lsdata}" var="className" varStatus="status">
    ${status.index}${className}
</c:forEach>
<br/>
<c:forEach begin="1" end="20" var="num">
    ${num}
</c:forEach>
<br/>
时间日期格式化处理演示
<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>
</body>
</html>
